
using System.Collections.Generic;
using PolicyAlgebra.Util;

namespace PolicyAlgebra.Type
{
	///<summary>
	///    This class defines the actual policy. Or at least the main part of it.
	///    It represents the set of all associations between a role and permissions
	///    over an object. Although it is algibraically considered a set, it is
	///    actually implemented as a hashtable / dictionary.
	///</summary>
	public class RoleObjectPermissionSetSetAssociationDict
	{ 
		private Dictionary<Role,ObjectPermissionSetSetAssociationSet> dict;

		///<summary>
		/// Constructor.
		///</summary>
		public RoleObjectPermissionSetSetAssociationDict()
		{
			dict = new Dictionary<Role,ObjectPermissionSetSetAssociationSet>();
		}

		public void Add(Role key, ObjectPermissionSetSetAssociationSet val)
		{
			if (dict.ContainsKey(key))
			{
				dict[key].AddMembers(val);
			} else
			{
				dict.Add(key,val);
			}
		}
	}
}
